#include<bits/stdc++.h>
using namespace std;
int ans[20];
int main(){
freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
int t;
cin>>t;
for(int i=1;i<=t;i++){
    int n,m,l,v;
    cin>>n>>m>>l>>v;
    int che[n][3],ce[m];
    for(int j=0;j<n;j++)cin>>che[j][0]>>che[j][1]>>che[j][2];
    for(int j=0;j<m;j++)cin>>ce[j];
    for(int j=0;j<n;j++){
        if(che[j][0]<=ce[m-1]&&che[j][1]>v)ans[i-1]++;
    }
}
for(int i=1;i<=t;i++){
    cout<<ans[i-1]<<endl;
}
return 0;
}

